package com.itheima.tlias84.aop.cglib;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class EatIntereceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
       // System.out.println("刷牙");
        long l = System.currentTimeMillis();
        //调用父类的方法
        proxy.invokeSuper(obj,args); //obj 相当于是调用父类的方法 Dog类 被增强的对象
        //System.out.println("洗漱");
        long l1 = System.currentTimeMillis()-l;
        System.out.println("执行时间"+l1);
        return obj;
    }
}
